package com.yds.modewithprinceple;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.yds.modewithprinceple.builder.BuilderPatternActivity;
import com.yds.modewithprinceple.databinding.ActivityMainBinding;
import com.yds.modewithprinceple.factory.FactoryPatternActivity;
import com.yds.modewithprinceple.prototype.PrototypePatternActivity;
import com.yds.modewithprinceple.singleton.SingletonPatternActivity;
import com.yds.modewithprinceple.strategy.StrategyPatternActivity;

@SuppressWarnings("all")
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        binding.btSingletonPattern.setOnClickListener(this);
        binding.btBuilderPattern.setOnClickListener(this);
        binding.btPrototypePattern.setOnClickListener(this);
        binding.btFactoryPattern.setOnClickListener(this);
        binding.btStrategyPattern.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btSingletonPattern://单例模式
                startActivity(new Intent(MainActivity.this, SingletonPatternActivity.class));
                break;
            case R.id.btBuilderPattern://Builder模式
                startActivity(new Intent(MainActivity.this, BuilderPatternActivity.class));
                break;
            case R.id.btPrototypePattern://原形模式
                startActivity(new Intent(MainActivity.this, PrototypePatternActivity.class));
                break;
            case R.id.btFactoryPattern://工厂模式
                startActivity(new Intent(MainActivity.this, FactoryPatternActivity.class));
                break;
            case R.id.btStrategyPattern://策略模式
                startActivity(new Intent(MainActivity.this, StrategyPatternActivity.class));
                break;
        }
    }
}